function throttle(fn, delay) {
  let before = 0;
  return function (...args) {
    let now = new Date().getTime();
    if (now - before > delay) {
      before = now;
      fn.apply(this, args);
    }
    return;
  };
}

window.addEventListener("load", () => {
  const section = document.querySelector("section");
  section.addEventListener(
    "scroll",
    throttle(() => {
      console.log("节流函数");
    }, 1000)
  );
});
